package model

import(
	//"my_server_test/config"
	"my_server_test/databest"
	"my_server_test/datamodel"
	"my_server_test/systemcode"
	"my_server_test/function"
	// "time"
)

func LoginJudgo(sys *datamodel.SystemAdmin,username string,pwd string,code string) int{
	 //starttime := time.Now().Unix()
	 list, err :=databest.Engine.Where("`user_name` = ? ", username).And("`password` = ?", function.Md5Encryption(pwd)).Get(sys)
	if err != nil {
		return systemcode.SystemUser
	}
	if !list {
		return systemcode.Change;
	}
	// sys.LastLoginTime=starttime
	// sys.Updated=starttime
	// _, err =databest.Engine.Cols("last_login_time,device_type").ID(sys.Id).Update(sys)
	// if err != nil {
	// 	return systemcode.SystemUserUpdate
	// }
	return systemcode.SUCCESS
}